home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 August / ENTER.ISO / files / gimp-2.0.5-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / gradient-example.scm < prev    next >
Encoding:
Text File  |  2004-09-26  |  2.5 KB  |  72 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Gradient example script --- create an example image of a custom gradient
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. (define (script-fu-gradient-example width
  23.                     height
  24.                     gradient-reverse)
  25.   (let* ((img (car (gimp-image-new width height RGB)))
  26.      (drawable (car (gimp-layer-new img width height RGB
  27.                     "Gradient example" 100 NORMAL-MODE)))
  28.  
  29.      ; Save old foreground and background colors
  30.  
  31.      (old-fg-color (car (gimp-palette-get-foreground)))
  32.      (old-bg-color (car (gimp-palette-get-background)))
  33.  
  34.      ; Calculate colors for checkerboard... just like in the gradient editor
  35.  
  36.      (fg-color (* 255 (/ 2 3)))
  37.      (bg-color (* 255 (/ 1 3))))
  38.  
  39.     (gimp-image-undo-disable img)
  40.     (gimp-image-add-layer img drawable 0)
  41.  
  42.     ; Render background checkerboard
  43.  
  44.     (gimp-palette-set-foreground (list fg-color fg-color fg-color))
  45.     (gimp-palette-set-background (list bg-color bg-color bg-color))
  46.     (plug-in-checkerboard 1 img drawable 0 8)
  47.  
  48.     ; Render gradient
  49.  
  50.     (gimp-edit-blend drawable CUSTOM-MODE NORMAL-MODE
  51.              GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
  52.              FALSE 0 0 TRUE
  53.              0 0 (- width 1) 0)
  54.  
  55.     ; Terminate
  56.  
  57.     (gimp-palette-set-foreground old-fg-color)
  58.     (gimp-palette-set-background old-bg-color)
  59.     (gimp-image-undo-enable img)
  60.     (gimp-display-new img)))
  61.  
  62. (script-fu-register "script-fu-gradient-example"
  63.             _"<Toolbox>/Xtns/Script-Fu/Utils/Custom _Gradient..."
  64.             "Create an example image of a custom gradient"
  65.             "Federico Mena Quintero"
  66.             "Federico Mena Quintero"
  67.             "June 1997"
  68.             ""
  69.             SF-ADJUSTMENT _"Width"            '(400 1 2000 1 10 0 1)
  70.             SF-ADJUSTMENT _"Height"           '(30 1 2000 1 10 0 1)
  71.             SF-TOGGLE     _"Gradient Reverse" FALSE)
  72.